package logic

import (
	"context"
	"errors"
	"srv/model/mysql"

	"srv/internal/svc"
	"srv/renrenzu"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateGoodsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateGoodsLogic {
	return &UpdateGoodsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateGoodsLogic) UpdateGoods(in *renrenzu.UpdateGoodsRequest) (*renrenzu.UpdateGoodsResponse, error) {
	// todo: add your logic here and delete this line
	g := mysql.Goods{}
	err := g.UpdateGoods(int(in.GoodsId), int(in.GoodsState))
	if err != nil {
		logx.Error("修改状态失败")
		return nil, errors.New("修改状态失败")
	}
	return &renrenzu.UpdateGoodsResponse{Goods: true}, nil
}
